<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>竣工验收 - 申请</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="Cache-Control" content="no-siteapp,no-transform,no-store, no-cache, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/weadmin.css">
    <script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
    <!--<script type="text/javascript" src="/templates/act/process-xl.js"></script>-->
    <style>
        .content {
            position: relative;
        }

        .btnBox {
            position: absolute;
            top: 10px;
            right: 10px;
            z-index: 1000;
        }
    </style>
</head>
<body>
<div class="content" id="view">

</div>
<script src="/static/js/main.js"></script>
<script type="text/javascript">
    layui.use(['configureCom', 'configure', 'bluebird', 'baseTab', 'sessionFun', 'jquery', 'process'], function () {
        var configure = layui.configure;
        var configureCom = layui.configureCom;
        var baseTab = layui.baseTab;
        var sessionFun = layui.sessionFun;
        var process = layui.process;
        var $ = layui.jquery;

        // 流程待办信息
        var procWaitDealRowData = sessionFun.get(configure.SESSION_PROC_WAIT_DEAL_ROW_DATA);

        /***
         * sessionFun.set('baseData',{ prjId: data.businessId });
         * baseData 放进去的是 项目 ID
         */
        var prjId = sessionFun.get( 'prjId' );
        var project  = null;
        configureCom.getAjax(configure.PRJ_PROJECT_VIEW_API,{ prjId:prjId } ).then(function(res){
            project = res.data;
            sessionFun.set( 'PRJ_PROJECT_ENTITY' ,project);
        })



        var tasks = {};
        // 建设 - 工程竣工验收监督申请
        var jgysjdsq = {

            tabData :{
                btns: [
                    {name: '保存', event: 'save'},
                    {name: '保存并提交', event: 'submit'},
                    {name: '关闭', event: 'close'}
                ],
                tabList: [
                    { title: '项目信息', url: configure.UNIT_PROJECT_PROHIBITED_DETAIL_HTML},
                    { title: '竣工验收监督申请表', url:'/pages/jgys/jgys-jdsq.html'}
                ]
            },

            save: function(){
                configureCom.getData(1).then(function (res) {
                    configureCom.postAjax(configure.CPT_ACCEPTANCE_SAVE_API, res.result).then(function (res) {
                        top.layer.msg('保存成功！');
                    })
                });
            },

            submit: function() {
                configureCom.getData(1).then(function (res) {
                    top.layer.msg('保存成功！');
                    configureCom.postAjax(configure.CPT_ACCEPTANCE_SAVE_API, res.result).then(function (res) {
                        process.startProcess({
                            "title": "测试流程 - " + project.prjName,
                            "businessId": prjId,
                            "procDefKey": 'JGYS'
                        });
                    })
                });

            },

            init: function(){
                baseTab.init(this.tabData, 1);
                form.on('submit', function (data) {
                    var event = $(data.elem).attr('lay-event');
                    switch (event) {
                        case 'save':
                            jgysjdsq.save();
                            break;
                        case 'submit':
                            jgysjdsq.submit();
                            break;
                    }
                    return false;
                });
            }
        };

        // 监管 - 竣工验收条件核查
        var jgysjdtjhc = {

            tabData :{
                btns: [
                    {name: '保存', event: 'save'},
                    {name: '保存并提交', event: 'submit'},
                    {name: '关闭', event: 'close'}
                ],
                tabList: [
                    { title: '项目信息', url: configure.UNIT_PROJECT_PROHIBITED_DETAIL_HTML},
                    { title: '竣工验收监督申请表', url:'/pages/jgys/jgys-jdsq.html'},
                    { title: '工程竣工验收监督条件核查记录', url:'/pages/jgys/jgys-jdtjhc.html'}
                ]
            },

            save: function(){
                configureCom.getData(2).then(function (res) {
                    configureCom.postAjax(configure.CPT_ACCEPTANCE_CONDITION_SAVE_API, res.result).then(function (res) {
                        top.layer.msg('保存成功！');
                    })
                });
            },

            submit: function() {
                configureCom.getData(2).then(function (res) {
                    configureCom.postAjax(configure.CPT_ACCEPTANCE_CONDITION_SAVE_API, res.result).then(function (res) {
                        process.next({
                            "taskId": procWaitDealRowData.id,
                            "poId": procWaitDealRowData.poId
                        });
                    })
                });

            },

            init: function(){
                baseTab.init(this.tabData, 2);
                form.on('submit', function (data) {
                    var event = $(data.elem).attr('lay-event');
                    switch (event) {
                        case 'save':
                            jgysjdtjhc.save();
                            break;
                        case 'submit':
                            jgysjdtjhc.submit();
                            break;
                    }
                    return false;
                });
            }
        };

        // 建设 - 组织竣工验收
        var zzjgys = {

            tabData :{
                btns: [
                    {name: '通知监管机构进行竣工验收监督', event: 'submit'},
                    {name: '关闭', event: 'close'}
                ],
                tabList: [
                    { title: '项目信息', url: configure.UNIT_PROJECT_PROHIBITED_DETAIL_HTML},
                    { title: '竣工验收监督申请表', url:'/pages/jgys/jgys-jdsq.html'},
                    { title: '工程竣工验收监督条件核查记录', url:'/pages/jgys/jgys-jdtjhc.html'},
                    { title: '组织竣工验收', url:'/pages/jgys/jgys-zzjgys.html'}
                ]
            },

            submit: function() {
                process.next({
                    "taskId": procWaitDealRowData.id,
                    "poId": procWaitDealRowData.poId
                });
            },

            init: function(){
                baseTab.init(this.tabData, 3);
                form.on('submit', function (data) {
                    var event = $(data.elem).attr('lay-event');
                    switch (event) {
                        case 'submit':
                            zzjgys.submit();
                            break;
                    }
                    return false;
                });
            }
        };

        // 监管 - 竣工验收监督
        var jgysjd = {
            tabData :{
                btns: [
                    {name: '保存', event: 'save'},
                    {name: '保存并提交', event: 'submit'},
                    {name: '关闭', event: 'close'}
                ],
                tabList: [
                    { title: '项目信息', url: configure.UNIT_PROJECT_PROHIBITED_DETAIL_HTML},
                    { title: '竣工验收监督申请表', url:'/pages/jgys/jgys-jdsq.html'},
                    { title: '工程竣工验收监督条件核查记录', url:'/pages/jgys/jgys-jdtjhc.html'},
                    { title: '工程竣工验收监督', url:'/pages/jgys/jgys-jd.html'},
                ]
            },

            save: function(){
                configureCom.getData(3).then(function (res) {
                    configureCom.postAjax(configure.CPT_ACCEPTANCE_CONDITION_SAVE_API, res.result).then(function (res) {
                        top.layer.msg('保存成功！');
                    })
                });
            },

            submit: function() {
                configureCom.getData(3).then(function (res) {
                    configureCom.postAjax(configure.CPT_ACCEPTANCE_CONDITION_SAVE_API, res.result).then(function (res) {
                        process.next({
                            "taskId": procWaitDealRowData.id,
                            "poId": procWaitDealRowData.poId
                        });
                    })
                });

            },

            init: function(){
                baseTab.init(this.tabData, 3);
                form.on('submit', function (data) {
                    var event = $(data.elem).attr('lay-event');
                    switch (event) {
                        case 'save':
                            jgysjd.save();
                            break;
                        case 'submit':
                            jgysjd.submit();
                            break;
                    }
                    return false;
                });
            }
        };

        // 填写竣工验收结论
        var txysjl = {

            tabData :{
                btns: [
                    {name: '保存', event: 'save'},
                    {name: '保存并提交', event: 'submit'},
                    {name: '关闭', event: 'close'}
                ],
                tabList: [
                    { title: '项目信息', url: configure.UNIT_PROJECT_PROHIBITED_DETAIL_HTML},
                    { title: '竣工验收监督申请表', url:'/pages/jgys/jgys-jdsq.html'},
                    { title: '工程竣工验收监督条件核查记录', url:'/pages/jgys/jgys-jdtjhc.html'},
                    { title: '工程竣工验收监督', url:'/pages/jgys/jgys-jd.html'},
                    { title: '工程竣工意见结论', url:'/pages/jgys/jgys-txysjl.html'}
                ]
            },

            save: function(){
                configureCom.getData(4).then(function (res) {
                    configureCom.postAjax(configure.CPT_ACCEPTANCE_CONDITION_SAVE_API, res.result).then(function (res) {
                        top.layer.msg('保存成功！');
                    })
                });
            },

            submit: function() {
                configureCom.getData(4).then(function (res) {
                    configureCom.postAjax(configure.CPT_ACCEPTANCE_CONDITION_SAVE_API, res.result).then(function (res) {
                        process.next({
                            "taskId": procWaitDealRowData.id,
                            "poId": procWaitDealRowData.poId
                        });
                    })
                });

            },

            init: function(){
                baseTab.init(this.tabData, 4);
                form.on('submit', function (data) {
                    var event = $(data.elem).attr('lay-event');
                    switch (event) {
                        case 'save':
                            txysjl.save();
                            break;
                        case 'submit':
                            txysjl.submit();
                            break;
                    }
                    return false;
                });
            }
        };


        if(procWaitDealRowData!=null){
            var taskDefKey =  procWaitDealRowData.taskDefKey;
            if(taskDefKey === 'jgysjdtjhc' ){
                jgysjdtjhc.init();
            }else if(taskDefKey === 'zzjgys'){
                zzjgys.init();
            }else if(taskDefKey === 'jgysjd'){
                jgysjd.init();
            }else if(taskDefKey === 'txysjl'){
                txysjl.init();
            }else if(taskDefKey === 'jgysjdsq'){
                jgysjdsq.init();
            }

        }else{
            jgysjdsq.init();
        }

        sessionFun.remove(configure.SESSION_PROC_WAIT_DEAL_ROW_DATA);


    });


</script>
</body>
</html>